﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admincp/Admin.Master" AutoEventWireup="true" CodeBehind="~/Admincp/Dondathang.aspx.cs" Inherits="TPCN.Admincp.Dondathang" %>

<script runat="server">

    protected void ChitietdondathangGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="name" ContentPlaceHolderID="nameholder" runat="server">Đơn đặt hàng</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </telerik:RadScriptManager>


    <asp:Panel ID="ButtonPanel" runat="server" CssClass="right">
        <asp:Button ID="btnInsert" runat="server" Text="Thêm mới" CssClass="button button-green"
            OnClick="btnInsert_Click" />
        <asp:Button ID="btnDelete" runat="server" Text="Xóa" CssClass="button button-green"
            OnClick="btnDelete_Click" OnClientClick="if(!confirm('Bạn có muốn xóa những dòng đã chọn không?')) return false;" />
    </asp:Panel>
    <asp:Panel ID="ErrorPanel" runat="server">
        <asp:ValidationSummary ID="summary" runat="server" CssClass="message error" />
    </asp:Panel>

    <hr />

    <!-- For Order -->

    <asp:Panel ID="GridViewPanel" runat="server">
        <asp:GridView ID="OrderGridView" runat="server" AutoGenerateColumns="False" Width="100%"
            DataKeyNames="DonDatHangID" Height="16px" OnRowCommand="OrderGridView_RowCommand"
            AllowPaging="True" GridLines="None" CssClass="mGrid" AlternatingRowStyle-CssClass="alt"
            PagerStyle-CssClass="pgr" OnPageIndexChanging="OrderGridView_PageIndexChanging"
            PageSize="15">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkItem" />
                    </ItemTemplate>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkHeader" />
                    </HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </asp:TemplateField>
                <asp:BoundField DataField="DondathangID" HeaderText="Mã đơn đặt hàng" ReadOnly="True">
                    <HeaderStyle CssClass="hide" />
                    <ItemStyle CssClass="hide" />
                </asp:BoundField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="cmdViewDetail" runat="server" CommandArgument='<%# Eval("DondathangID") %>'
                            CommandName="cmdViewDetail">Chi tiết</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:BoundField DataField="Hotennguoinhan" HeaderText="Người nhận" />
                <asp:BoundField DataField="Sodienthoai" HeaderText="Điện thoại"></asp:BoundField>
                <asp:TemplateField HeaderText="Nhận hàng">
                    <ItemTemplate>
                        <asp:Literal ID="lblHinhthucnhanhang" runat="server" Text='<%# DisplayDeliver(Eval("Hinhthucnhanhang"),Eval("Diachinhanhang")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày đặt">
                    <ItemTemplate>
                        <asp:Literal ID="lblNgaylap" runat="server" Text='<%# FormatDatetime(Eval("Ngaylap")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Xác nhận">
                    <ItemTemplate>
                        <asp:Image ID="icon" runat="server" ImageUrl='<%# BuildIconPath(Eval("DondathangID")) %>' />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="btn_CMD_Edit" runat="server" CommandArgument='<%# Eval("DondathangID") %>'
                            CommandName="cmdEdit">Sửa</asp:LinkButton>
                        <asp:LinkButton ID="btn_CMD_Delete" runat="server" CommandArgument='<%# Eval("DondathangID") %>'
                            CommandName="cmdDelete" OnClientClick="return confirm('Bạn có muốn xóa đơn đặt hàng này không?');">Xóa</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
            <PagerSettings FirstPageText="Đầu" LastPageText="Cuối" Mode="NumericFirstLast" NextPageText="Tiếp"
                PreviousPageText="Trước" PageButtonCount="5" />
            <PagerStyle CssClass="pgr" />
        </asp:GridView>
    </asp:Panel>

    <asp:Panel ID="OrderEditFormPanel" runat="server">
        <table id="OrderlEditForm">
            <tbody>
                <tr>
                    <td class="label">
                        Tên người nhận
                    </td>
                    <td>
                        <asp:TextBox ID="txtHotennguoinhan" runat="server" Width="230px"></asp:TextBox>
                    </td>
                    <td class="label">
                        Điện thoại
                    </td>
                    <td>
                        <asp:TextBox ID="txtSodienthoai" runat="server" Width="230px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Thanh toán
                    </td>
                    <td>
                        <asp:DropDownList ID="cboThanhtoan" runat="server" Width="243px">
                        </asp:DropDownList>
                    </td>
                    <td class="label">
                        Nhận hàng
                    </td>
                    <td>
                        <asp:DropDownList ID="cboNhanhang" runat="server" Width="243px" OnSelectedIndexChanged="cboNhanhang_SelectedIndexChanged"
                            AutoPostBack="true">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Địa chỉ nhận hàng
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtAddress" runat="server" Width="548px" Enabled="false" />
                    </td>
                </tr>
                <tr>
                    <td class="label top">
                        Ghi chú
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" Width="548px" Height="200px" />
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Hiển thị
                    </td>
                    <td colspan="3">
                        <asp:CheckBox ID="chkActive" runat="server" />
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="center">
            <asp:Button ID="btnSave" runat="server" Text="Cập nhật" CssClass="button button-green groupbutton"
                OnClick="btnSave_Click" />
            <asp:Button ID="btnCancel" runat="server" Text="Hủy bỏ" CssClass="button button-green groupbutton"
                OnClick="btnCancel_Click" TabIndex="12" CausesValidation="False" UseSubmitBehavior="False"
                EnableViewState="False" />
        </div>
    </asp:Panel>
    <div class="clear">
    </div>

    <!-- For Order Detail -->

    <asp:Panel ID="OrderDetailPanel" runat="server">

        <div class="orderdetail message info">
            <div class="order-row">
                <span>Họ tên người nhận : </span>
                <asp:Literal ID="lblNguoinhan" runat="server"></asp:Literal>
            </div>
            <div class="order-row">
                <span>Điện thoại liên hệ : </span>
                <asp:Literal ID="lblSodienthoai" runat="server"></asp:Literal>
            </div>
            <div class="order-row">
                <span>Nhận hàng tại : </span>
                <asp:Literal ID="lblNhanhang" runat="server"></asp:Literal>
            </div>
            <div class="order-row">
                <span>Hình thức thanh toán : </span>
                <asp:Literal ID="lblThanhtoan" runat="server"></asp:Literal>
            </div>
        </div>

        <div class="message info order-status">
            <div class="order-row">
                <span>Đã xác nhận : </span>
                <asp:CheckBox ID="chkConfirmed" runat="server" />
            </div>
            <div class="order-row">
                <span>Đang giao hàng : </span>
                <asp:CheckBox ID="chkDelivering" runat="server" />
            </div>
            <div class="order-row">
                <span>Đã giao hàng : </span>
                <asp:CheckBox ID="chkDelivered" runat="server" />
            </div>
            <div class="order-row">
                <span>Đã thanh toán : </span>
                <asp:CheckBox ID="chkPaid" runat="server" />
            </div>
            <div class="clear"></div>
        </div>

        <div class="updatestatus">
            <asp:Button ID="btnUpdateStatus" runat="server" CssClass="button button-blue" 
                Text="Cập nhật trạng thái" onclick="btnUpdateStatus_Click" />
        </div>

        <asp:GridView ID="ChitietdondathangGridView" runat="server" 
            AutoGenerateColumns="False" Width="100%"
            DataKeyNames="DonDatHangID" Height="16px" AllowPaging="True" 
            GridLines="None" CssClass="mGrid" AlternatingRowStyle-CssClass="alt"
            PagerStyle-CssClass="pgr"
            PageSize="15" onrowcommand="ChitietdondathangGridView_RowCommand" 
            onpageindexchanging="ChitietdondathangGridView_PageIndexChanging">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkItem" />
                    </ItemTemplate>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkHeader" />
                    </HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </asp:TemplateField>
                <asp:BoundField DataField="HangID" HeaderText="Mã hàng" ReadOnly="True">
                    <HeaderStyle CssClass="hide" />
                    <ItemStyle CssClass="hide" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Tên hàng">
                    <ItemTemplate>
                        <asp:Literal ID="lblProductName" runat="server" Text='<%# GetProductNameFromID(Eval("HangID")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Soluong" HeaderText="Số lượng" />
                <asp:BoundField DataField="Ghichu" HeaderText="Ghi chú"></asp:BoundField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="btn_CMD_Edit" runat="server" CommandArgument='<%# Eval("ChitietDondathangID") %>'
                            CommandName="cmdEdit">Sửa</asp:LinkButton>
                        <asp:LinkButton ID="btn_CMD_Delete" runat="server" CommandArgument='<%# Eval("ChitietDondathangID") %>'
                            CommandName="cmdDelete" OnClientClick="return confirm('Bạn có muốn xóa mặt hàng này không?');">Xóa</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
            <PagerSettings FirstPageText="Đầu" LastPageText="Cuối" Mode="NumericFirstLast" NextPageText="Tiếp"
                PreviousPageText="Trước" PageButtonCount="5" />
            <PagerStyle CssClass="pgr" />
        </asp:GridView>
        <div class="backButton clear">
            <asp:Button ID="btnBack" runat="server" CssClass="button button-green" 
                Text="Trở lại" onclick="btnBack_Click" />
        </div>
    </asp:Panel>

    <asp:Panel ID="OrderDetailEditPanel" runat="server">
        <table id="OrderDetailEditForm">
            <tbody>
                <tr>
                    <td class="label">
                        Sản phẩm
                    </td>
                    <td>
                        <asp:DropDownList ID="cboProduct" runat="server" Width="255px" />
                    </td>
                    <td class="label">
                        Số lượng
                    </td>
                    <td>
                        <asp:TextBox ID="txtSoluong" runat="server" Width="230px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="label top">
                        Ghi chú
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtProductComment" runat="server" TextMode="MultiLine" Width="548px" Height="200px" />
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="center clear">
            <asp:Button ID="btnSave_Detail" runat="server" Text="Cập nhật" CssClass="button button-green groupbutton"
                OnClick="btnSave_Click" />
            <asp:Button ID="btnCancel_Detail" runat="server" Text="Hủy bỏ" CssClass="button button-green groupbutton"
                OnClick="btnCancel_Click" TabIndex="12" CausesValidation="False" UseSubmitBehavior="False"
                EnableViewState="False" />
        </div>
    </asp:Panel>

    <!-- For Ajax Manager -->

    <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="GridViewPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="GridViewPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="OrderDetailPanel" />
                    <telerik:AjaxUpdatedControl ControlID="OrderEditFormPanel" />
                    <telerik:AjaxUpdatedControl ControlID="ButtonPanel" />
                    <telerik:AjaxUpdatedControl ControlID="OrderDetailEditPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="OrderDetailPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="OrderDetailPanel" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ButtonPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="GridViewPanel" LoadingPanelID="loadingPanel"/>
                    <telerik:AjaxUpdatedControl ControlID="OrderDetailPanel" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>
